package bmcsoft.test.recursive;
import java.util.Scanner;
//ComputeFactorial.java
public class ComputeFactorial {
    /**Main method*/
    public static void main(String[] args){
        //Create a Scanner;
        Scanner input = new Scanner(System.in);
        System.out.println("Enter a nonnegative integer: ");
        double n = input.nextDouble();


        //Display factorial;
        System.out.println("Factorial of " + n +" is " + factorial(n));
    }
    /** Return the factorial for the specified number*/
    private static double factorial(double n){
        if (n == 0)//Base case;
            return 1;
        else
            return n*factorial(n-1);
    }
}
